import type { IResData } from '../indexTypes';
import { exc, root } from '../apiRoot';
import { defHttp } from '@/utils/http';
import type { PhotoAlbumDetailsResult, PhotoAlbumGroupListResult, PhotoAlbumListResult, PhotoListResult } from './types';

const Api = {
  photoAlbumGroupList: root + 'photoAlbumGroup/list',
  photoAlbumList: root + 'photoAlbum/list',
  newPhotoAlbumList: root + 'photoAlbum/listWithWxtraInfo',
  photoList: root + 'photo/list',
  homePhtotoList: exc + 'photoAlbum/app/indexList',
  photoAlbumDetails: root + 'photoAlbum/details',
};

/**
 * @description 获取首页相册列表
 * @date 09/08/2022
 * @export
 * @param {{ current: number; size: number }} data
 */
export function homePhtotoList(data: { current: number; size: number }) {
  return defHttp.get<IResData<PhotoAlbumListResult>>({
    url: Api.homePhtotoList,
    data,
  });
}

/**
 * @description 获取相册分组
 * @date 08/08/2022
 * @export
 */
export function photoAlbumGroupList() {
  return defHttp.get<PhotoAlbumGroupListResult[]>({
    url: Api.photoAlbumGroupList,
  });
}

/**
 * @description 获取相册列表
 * @date 08/08/2022
 * @export
 * @param {{ belongId: number }} data 分类id
 */
export function photoAlbumList(data: { belongId: number }) {
  return defHttp.get<IResData<PhotoAlbumListResult>>({
    url: Api.photoAlbumList,
    data,
  });
}

/**
 * @description 获取相册列表 带浏览信息和相册容量
 * @date 10/05/2023
 * @export
 * @param {{ belongId: number }} data 分类id
 */
export function newPhotoAlbumList(data: { belongId: number }) {
  return defHttp.get<IResData<PhotoAlbumListResult>>({
    url: Api.newPhotoAlbumList,
    data,
  });
}

/**
 * @description 获取相册中相片列表
 * @date 09/08/2022
 * @export
 * @param {{ belongId: number }} data
 */
export function photoList(data: { belongId: number }) {
  return defHttp.get<IResData<PhotoListResult>>({
    url: Api.photoList,
    data,
  });
}

/**
 * @description 相册详情
 * @date 15/08/2022
 * @export
 * @param {number} id 相册id
 */
export function photoAlbumDetails(id: number) {
  return defHttp.get<PhotoAlbumDetailsResult>({
    url: Api.photoAlbumDetails + `/${id}`,
  });
}
